<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<script type="text/javascript">
			//1、修改每个th td的颜色
			
			
			//2、从数据列表开始单数行为蓝色，偶数行为红色（Js代码生成）
			
			window.onload=function(){
				var table=document.getElementsByTagName("table");
				var th=table[0].getElementsByTagName("th");
				th[0].style.background="blue";
				th[1].style.background="red";
				th[2].style.background="yellow";
				th[3].style.background="green";
				th[4].style.background="cyan";
				
				
				for(var a=0;a<3;a++){
					var tr=document.createElement("tr");
						
					for(var b=0;b<5;b++){
						var txt=document.createTextNode("文字");
						var td=document.createElement("td");
						td.appendChild(txt);
						tr.appendChild(td);
					}
					table[0].appendChild(tr);
					
				}
				var tr2=document.getElementsByTagName("tr")[1];
				var tr3=document.getElementsByTagName("tr")[2];
				var tr4=document.getElementsByTagName("tr")[3];
				for(var a=0;a<tr2.getElementsByTagName("td").length;a++){
					var td2=tr2.getElementsByTagName("td")[a];
					var td3=tr3.getElementsByTagName("td")[a];
					var td4=tr4.getElementsByTagName("td")[a];
					td2.style.color="blue";
					td3.style.color="red";
					td4.style.color="blue";
					
//					td2.style.background="blue";
//					td3.style.background="red";
//					td4.style.background="blue";
				}
			}
		</script>
	</head>
	<body>
		<table border="1">
				<tr>
					<th class="" >部门名称</th>
					<th class="">部门电话</th>
					<th class="">部门负责人</th>
					<th class="">所属单位</th>
					<th class="">操作</th>
				</tr>
				<!--<tr id="xy">
					<td>1</td>
					<td>1</td>
					<td>1</td>
					<td>1</td>
					<td>1</td>
				</tr>
				<tr class="tt">
					<td>1</td>
					<td>1</td>
					<td>1</td>
					<td>1</td>
					<td>1</td>
				</tr>
				<tr>
					<td>1</td>
					<td>1</td>
					<td>1</td>
					<td>1</td>
					<td>1</td>
				</tr>-->
		</table>
	</body>
</html>
